package cn.edu.tsinghua.training.cms.demo.service.impl;

import java.io.Serializable;
import java.util.List;

import cn.edu.tsinghua.training.cms.demo.dao.GenericDao;
import cn.edu.tsinghua.training.cms.demo.service.GenericService;
import cn.edu.tsinghua.training.cms.demo.util.PageBean;

public class GenericServiceImpl<E extends Serializable, ID extends Serializable> implements GenericService<E, ID> {

	protected GenericDao<E, ID> genericDao;
	
	@Override
	public ID add(E e) {
		return genericDao.add(e);
	}

	@Override
	public List<E> query(String hql, String[] paramNames, Object[] values) {
		return genericDao.query(hql, paramNames, values);
	}

	@Override
	public List<E> queryAll() {
		return genericDao.queryAll();
	}

	@Override
	public E queryById(ID id) {
		return genericDao.queryById(id);
	}

	@Override
	public void update(E e) {
		genericDao.update(e);
	}

	@Override
	public void delete(E e) {
		genericDao.delete(e);
	}
	
	public void setGenericDao(GenericDao<E, ID> genericDao) {
		this.genericDao = genericDao;
	}

	@Override
	public PageBean queryForPage(String hql, String[] params, Object[] values, int pageSize, int page) {
		return genericDao.queryForPage(hql, params, values, pageSize, page);
	}
	
}
